package com.kk.framework.session;

import javax.servlet.http.HttpSession;

import org.zkoss.zk.ui.Executions;

import com.kk.framework.util.Constants;

public class SystemSessionManager 
{
	/**
	 * 获取全局用户Session对象
	 * @return
	 */
	public static UserSessionObject getGblUserSessionData()
	{
		UserSessionObject userSessionObject = (UserSessionObject) Executions.getCurrent().getSession().getAttribute(Constants.SESS_NAME_USER_SESSION_OBJ);
		return userSessionObject;
	}
	
	public static void setGblUserSessionData(UserSessionObject uso)
	{
		Executions.getCurrent().getSession().setAttribute(Constants.SESS_NAME_USER_SESSION_OBJ, uso);
	}
	
	/**
	 * 获取全局系统Session变量
	 * @return
	 */
	public static SystemSessionObject getGblSysSessionData()
	{
		Object rawObj = Executions.getCurrent().getSession().getAttribute(Constants.SESS_NAME_SYS_SESSION_OBJ);
		return (SystemSessionObject)rawObj;
	}
	
	public static void setGblSysSessionData(SystemSessionObject sso)
	{
		Executions.getCurrent().getSession().setAttribute(Constants.SESS_NAME_SYS_SESSION_OBJ, sso);
	}
	
	public static String getSessionId()
	{
		String sessionId = ((HttpSession)Executions.getCurrent().getSession().getNativeSession()).getId();
		return sessionId;
	}
	
}
